#ifndef _BATTLE_HELPER_
#define _BATTLE_HELPER_

#include "Box2D\Box2D.h"

/// @brief provide co-ordination transform for battlescene
class BattleHelper
{
public:
	static void setRatio(float _ratio) { ratio = _ratio;	}
	void static setMapHW(float _W, float _H)  {	W = _W / 2;	H = _H / 2;	}

	inline static float getRatio() {	return ratio; }
	/// @brief set the height and width of the map
	inline static void getMapHW(float& _W, float& _H) {	_W = W; _H = H; }
	/**
	 * @brief unit transform from hge(pixel) to Box2d(MKS)
	 *
	 * @param length length in HGE
	 *
	 * @return length in Box2d
	 */
	inline static float getBox2dLengthFromHge(float length) {	return length / ratio;	}
	inline static void getBox2dCoordinateFromHge(float& dx, float& dy, float sx, float sy) 
	{
		dx = (sx - W) / ratio;
		dy = (sy - H) / ratio;
	}
	inline static const b2Vec2 getBox2dCoordinateFromHge(const b2Vec2& src)
	{
		return b2Vec2((src.x - W) / ratio, (src.y - H) / ratio);
	}

	/**
	 * @brief unit transform from box2d(MKS) to hge(pixel)
	 *
	 * @param length length in HGE
	 *
	 * @return length in Box2d
	 */
	inline static float getHgeLengthFromBox2d(float length) {	return length * ratio;	}
	inline static void getHgeCoordinateFromBox2d(float& dx, float& dy, float sx, float sy)
	{
		dx = sx * ratio + W;
		dy = sy * ratio + H;
	}
	inline static const b2Vec2 getHgeCoordinateFromBox2d(const b2Vec2& src)
	{
		return b2Vec2(src.x * ratio + W, src.y * ratio + H);
	}

private:
	/// @brief can' t be instantiated
	BattleHelper() {}
	/// @brief LengthInHge/LengthInBox2d
	static float ratio;
	/// @brief half width and height of map
	static float W, H;
};


#endif